using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class WeaponRecoil : MonoBehaviour
{
    [SerializeField] Transform recoilFollowPos;
    [SerializeField] float kickBackAmount=-1;
    [SerializeField] float kickBackSpeed=10,returnSpeed=2;
    float currentRecoilPosition, finaRecoilPosition;
    // Start is called before the first frame update
   
    void Update()
    {
        currentRecoilPosition = Mathf.Lerp(currentRecoilPosition, 0, returnSpeed * Time.deltaTime);
        finaRecoilPosition = Mathf.Lerp(finaRecoilPosition, currentRecoilPosition, kickBackSpeed * Time.deltaTime);
        recoilFollowPos.localPosition = new Vector3(0, 0, finaRecoilPosition);
    }
    public void TriggerRecoil() => currentRecoilPosition += kickBackAmount;
    
}
